from typing import List, Dict

from wechaty import Message
from wechaty_plugin_contrib.contrib import (
    RoomInviterPlugin
)
from wechaty_plugin_contrib.matchers import (
    MessageMatcher,
    RoomMatcher
)
from wechaty_plugin_contrib.message_controller import message_controller
from wechaty_puppet import get_logger

HowlaisiJoinRoomLogger = get_logger("HowlaisiJoinRoom", file='../HowlaisiJoinRoom.log')


class HowlaisiJoinRoomPlugin(RoomInviterPlugin):
    # VIEW_URL = '/api/plugins/ding_dong/view'
    @message_controller.may_disable_message
    async def on_message(self, msg: Message) -> None:
        # todo:后面接入宇道源码，让此处的关键字可配置
        self.rules: Dict[MessageMatcher, List[RoomMatcher]] = {
            MessageMatcher('进群'): [RoomMatcher('个人云原生')],
            MessageMatcher('测试群'): [RoomMatcher('测试群')]
        }
        await super().on_message(msg)
        message_controller.disable_all_plugins(msg)
